package com.rmb.service.impl;

import com.rmb.mapper.EtlDataEngineTypeMapper;
import com.rmb.entity.EtlDataEngineType;
import com.rmb.service.EtlDataEngineTypeService;
import org.springframework.stereotype.Service;
import org.springframework.test.annotation.Rollback;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * (EtlDataEngineType)表服务实现类
 *
 * @author makejava
 * @since 2021-01-13 10:31:43
 */
@Service("etlDataEngineTypeService")
@Transactional(rollbackFor = Exception.class)
public class EtlDataEngineTypeServiceImpl implements EtlDataEngineTypeService {
    @Resource
    private EtlDataEngineTypeMapper etlDataEngineTypeMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public EtlDataEngineType queryById(Long id) {
        return this.etlDataEngineTypeMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<EtlDataEngineType> queryAllByLimit(int offset, int limit) {
        return this.etlDataEngineTypeMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param etlDataEngineType 实例对象
     * @return 实例对象
     */
    @Override
    public EtlDataEngineType insert(EtlDataEngineType etlDataEngineType) {
        this.etlDataEngineTypeMapper.insert(etlDataEngineType);
        return etlDataEngineType;
    }

    /**
     * 修改数据
     *
     * @param etlDataEngineType 实例对象
     * @return 实例对象
     */
    @Override
    public EtlDataEngineType update(EtlDataEngineType etlDataEngineType) {
        this.etlDataEngineTypeMapper.update(etlDataEngineType);
        return this.queryById(etlDataEngineType.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.etlDataEngineTypeMapper.deleteById(id) > 0;
    }
}